﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;



namespace Project
{
    public partial class student : Form
    {
        private OleDbConnection bookConn;
        private OleDbCommand oleDbCmd = new OleDbCommand();

        private String connParam = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Properties.Settings.Default.database + ";Persist Security Info=False";

        string bookId;
        string bookName;
        string studentID;
        
        public student(string bookid, string bookname)
        {
            bookId = bookid;
            bookName = bookname;
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {




            Form rent = new rent(bookId,studentID ,bookName , "none");
           
            this.Dispose(); rent.ShowDialog();
        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            gridStudent.DataSource = null;

            gridStudent.Rows.Clear();

            gridStudent.Refresh();

            sqlCommands result = new sqlCommands();

            string sqlStatement = result.searchStudent("remove it later");

            OleDbDataAdapter dAdapter = new OleDbDataAdapter(sqlStatement, connParam);

            OleDbCommandBuilder cBuilder = new OleDbCommandBuilder(dAdapter);


            DataTable dataTable = new DataTable();

            DataSet ds = new DataSet();

            dAdapter.Fill(dataTable);

            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                gridStudent.Rows.Add(dataTable.Rows[i][3], dataTable.Rows[i][1] + " " + dataTable.Rows[i][2]);


            }  
        }

        private void gridStudent_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            studentID = gridStudent.Rows[e.RowIndex].Cells[0].Value.ToString();
        }
    }
}
